package cn.edu.stu.contorller.common;

import cn.edu.stu.bean.AjaxResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Karl
 * @Date 2022/12/12 - 13:44
 */
@RestController
public class ErrorController {

    @RequestMapping("/myError")
    public AjaxResult error(HttpServletRequest request){
        Object error = request.getAttribute("error");

        return AjaxResult.error(error==null?"发生错误":error.toString());
    }
}
